{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "77a287e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "510319e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pythonlib import boolean as boolean\n",
    "from pythonlib import boolean_net as boolean_net"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e5d7a884",
   "metadata": {},
   "outputs": [],
   "source": [
    "#qtimes_bv_bv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "deb183c9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def reverse_boolean(b):\n",
    "    return(not(b))\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "321a1d73",
   "metadata": {},
   "outputs": [],
   "source": [
    "def add_noise(np_array,percentage):\n",
    "    noise=np.random.rand(*np_array.shape)>percentage\n",
    "    print (noise)\n",
    "    return vect_element_noise(np_array,noise)\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "edf05802",
   "metadata": {},
   "outputs": [],
   "source": [
    "def element_noise(element, noise):\n",
    "    if noise:\n",
    "        return reverse_boolean(element)\n",
    "    else:\n",
    "        return element"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "2f4dea2c",
   "metadata": {},
   "outputs": [],
   "source": [
    "vect_element_noise=np.vectorize(element_noise)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
